package com.maixin.code.action;

import java.util.List;

import com.maixin.code.base.BaseAction;
import com.maixin.code.entity.Menus;
import com.maixin.code.service.MenusService;
import com.maixin.code.utils.Json2JavaUtils;

public class MenusAction  extends BaseAction{

	private static final long serialVersionUID = 1L;
	
	private MenusService menusSer;
	private Menus menus;
	private List<Menus> list;
	private String content;
	private Integer cnt;
	private String node;
	private String id;
	
	
	/**
	 * 查询数据字典分页数据
	 * @return
	 * @throws Exception
	 */
	public String selAllDataDic() throws Exception{
		list = menusSer.getMenusDAO().findAllMenus(start, limit);
		cnt = menusSer.getBaseDao().findTabCnt(Menus.class);
		return SUCCESS;
	}
	
	public String findMenus() throws Exception{
		list = menusSer.getBaseDao().findByPropertes(new String[] {"patentid"}, new Integer []{Integer.parseInt(node)}, Menus.class);
		
		return SUCCESS;
	}
	
	/**
	 * 删除数据
	 * @return
	 * @throws Exception
	 */
	public String delMenus()throws Exception{
		menusSer.getBaseDao().delete(menus);
		return SUCCESS;
	}
	
	/**
	 * 新增和修改菜单
	 * @return
	 * @throws Exception
	 */
	public String addMenus() throws Exception {
			menus = (Menus) Json2JavaUtils.json2Java(content, Menus.class).get(0);
			if(null == menus.getId() || "".equals(menus.getId())){
				menus = menusSer.getBaseDao().save(menus);
			}else{
				menus = menusSer.getBaseDao().update(menus);
			}
		return SUCCESS;
	}
	
	
	public MenusService getMenusSer() {
		return menusSer;
	}
	public void setMenusSer(MenusService menusSer) {
		this.menusSer = menusSer;
	}
	public Menus getMenus() {
		return menus;
	}
	public void setMenus(Menus menus) {
		this.menus = menus;
	}
	public List<Menus> getList() {
		return list;
	}
	public void setList(List<Menus> list) {
		this.list = list;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public Integer getCnt() {
		return cnt;
	}
	public void setCnt(Integer cnt) {
		this.cnt = cnt;
	}




	public String getId() {
		return id;
	}




	public void setId(String id) {
		this.id = id;
	}




	public String getNode() {
		return node;
	}




	public void setNode(String node) {
		this.node = node;
	}

}
